package com.ruijie.acl.listener;

import java.io.Serializable;
import java.util.List;

import com.ruijie.acl.service.DeviceAclService;
import com.ruijie.emp.device.Device;
import com.ruijie.emp.device.DeviceInterface;
import com.ruijie.emp.device.event.DeviceEvent;
import com.ruijie.emp.device.service.DeviceService;
import com.ruijie.emp.type.DataOperateType;
import com.ruijie.foundation.bo.EntityObject;
import com.ruijie.foundation.event.BaseEntityEventListener;

public class DeviceAclListener extends BaseEntityEventListener<Device> implements DeviceEvent  {

	private DeviceService deviceService;
	
	private DeviceAclService deviceAclService;

    public DeviceService getDeviceService() {
		return deviceService;
	}

	public void setDeviceService(DeviceService deviceService) {
		this.deviceService = deviceService;
	}

	public DeviceAclService getDeviceAclService() {
		return deviceAclService;
	}

	public void setDeviceAclService(DeviceAclService deviceAclService) {
		this.deviceAclService = deviceAclService;
	}
	
	public void afterMultiRemoveAll() {
		// TODO Auto-generated method stub
		
	}

	public void afterUpdateSubnet(Device device) {
		// TODO Auto-generated method stub
		
	}

	public void licenseCheck(Long devNumOfDB) {
		// TODO Auto-generated method stub
		
	}

	public void syncTopoViewData(EntityObject entity,
			DataOperateType operateType) {
		// TODO Auto-generated method stub
		
	}
	
	public void beforeMultiRemoveAll() {
        List<Device> deviceList = deviceService.getAll();
        for (Device device : deviceList) {
            beforeRemove(device);
        }

    }
	
	public void beforeMultiRemove(Serializable[] ids) {
        for (Serializable id : ids) {
            beforeRemove(id);
        }
    }

    public void beforeRemove(Serializable id) {
        Device device = deviceService.get(id);
        beforeRemove(device);
    }

	public void beforeRemove(Device entity) {
		deviceAclService.removeByDevice(entity);
    }

    @Override
    public void afterDeviceInterfaceUpdate(DeviceInterface deviceInterface) {
        // TODO Auto-generated method stub
        
    }

	


}